﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>
<%
	dim urls,Action,nid,name,paym,bip,mzf0,mzf,mzf1,mone,mone1,lib,page,bi,tupic
        Action=Request.QueryString("Action")
        urls=Request.QueryString("urls")
        nid=Request.QueryString("nid")
	if nid="" then nid=1
	if not isnumeric(nid) then nid=1
	nid=clng(nid)
        if urls="" then urls="index.asp"
        if Action="" then Action="pay1"
if sid<>"Null" then
Set Rs = Server.CreateObject("Adodb.Recordset")
Sql1 = "select [name],[tupic],[paym],[bip] from [qingtian_shangpin] where [nid]="&nid
		Rs.Open Sql1,conn,1,1
		if not (rs.bof and rs.eof) then
                name=rs("name")
                paym=rs("paym")
                bip=rs("bip")
                tupic=rs("tupic")
                else
if v=0 then
Response.Write("<card title=""出错了""><p align="""&qingtian.px&""">")
else
Response.Write("<title>出错了</title></head><body>")
end if
                qingtian.err("该商品不存在")
			end if
			Rs.close
                namer=session("username")
Sql2 = "select [id],[money],[money1] from [qingtian_user] where [name]='"&namer&"'"
		Rs.Open Sql2,conn,1,1
		if not (rs.bof and rs.eof) then
                mone=rs("money")
                mone1=rs("money1")
                bid=clng(rs("id"))
			end if
			Rs.close
                        set rs=nothing
if clng(bip)=3 or clng(bip)=4 then
lib=1
elseif clng(bip)=1 or clng(bip)=2 then
lib=2
elseif clng(bip)=5 then
lib=3
else
lib=4
end if
if clng(bip)=1 or clng(bip)=3 or clng(bip)=5 then
mzf0=clng(mone)
mzf=clng(paym)
mzf1=0
bi=qingtian.bi
else
mzf0=clng(mone1)
mzf1=clng(paym)
mzf=0
bi=qingtian.bit
end if
select case v
case "0" 
we0="<br/>"
book="<input name='page' format='*N' size='4' maxlength='5'/>个<anchor>提交<go href='pay.asp?Action=pay2&amp;nid="&nid&"&amp;sid="&sidd&"' method='post'><postfield name=""page"" value=""$(page:n)"" /></go></anchor><br/>"
title="<card title=""购买商品""><p align="""&qingtian.px&""">"
case "1"
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
book=""&dao&"<form action=""pay.asp?Action=pay2&amp;nid="&nid&"&amp;sid="&sidd&""" method=""post""><input type=""text"" name=""page"" value="""" size=""4"" maxlength=""5""/>个<input type=""submit"" value=""提交""/></form>"&we0&""
title="<title>购买商品</title></head><body>"
End Select
qingtian.info		
select case Action
case "pay1"

%>
<%=title%><%=qingtian.qingsav("319")%>
<%=we%>选的好,"<%=name%>"每个<%=zi%><%=paym%><%=bi%><%=zi0%>!<br/>我要买<a href="pay.asp?Action=pay2&amp;page=20&amp;nid=<%=nid%>&amp;sid=<%=sidd%>">20个</a>,<a href="pay.asp?Action=pay2&amp;page=10&amp;nid=<%=nid%>&amp;sid=<%=sidd%>">10个</a>,<a href="pay.asp?Action=pay2&amp;page=1&amp;nid=<%=nid%>&amp;sid=<%=sidd%>">1个</a>或输入个数:(最小1个,最多1000个)<%=we0%><%=book%><%=we%>你有:<%=zi%><%=mzf0%><%=bi%><%=zi0%><br/>
<a href="viewdaoju.asp?nid=<%=nid%>&amp;sid=<%=sidd%>">返回上级页面</a><%=we0%>
<%=hr%>
<%=qingtian.qingsav("320")%><%=sou%><a href="chuwu.asp?sid=<%=sidd%>">我的物品</a>|<a href="shangchen.asp?sid=<%=sidd%>">商场</a>|<a href="index.asp?sid=<%=sidd%>">地盘</a><%=we0%>
<%

case "pay2"

	page=Request("page")
	if page="" or page<1 or page>1000 then page=1
	if not isnumeric(page) then page=1
	page=clng(page)
        Session.Abandon

%>
<%=title%><%=qingtian.qingsav("319")%>

<%=we%>请确认:<%=page%>个"<%=name%>",共计<%=zi%><%=page*paym%><%=bi%><%=zi0%>!<br/><a href="pay.asp?Action=pay3&amp;page=<%=page%>&amp;nid=<%=nid%>&amp;sid=<%=sidd%>">[确认购买]</a><br/>你有:<%=zi%><%=mzf0%><%=bi%><%=zi0%><a href="chongzhi.asp?sid=<%=sidd%>">充值</a><br/>马上<a href="chongzhi.asp?sid=<%=sidd%>">充值我的<%=qingtian.bit%></a><br/>
<a href="pay.asp?nid=<%=nid%>&amp;sid=<%=sidd%>">返回上级页面</a><%=we0%>
<%=hr%>
<%=qingtian.qingsav("320")%><%=sou%><a href="chuwu.asp?sid=<%=sidd%>">我的物品</a>|<a href="shangchen.asp?sid=<%=sidd%>">商场</a>|<a href="index.asp?sid=<%=sidd%>">地盘</a><%=we0%>
<%

case "pay3"

	page=Request.QueryString("page")
	if page="" or page<1 or page>1000 then page=1
	if not isnumeric(page) then page=1
	page=clng(page)
%>
<%=title%><%=qingtian.qingsav("319")%>
<%
if clng(mzf0)>=clng(page*paym) then
if session("tr")=1 then
%>
<%=we%>购买失败,请不要重复刷新!<br/>
<a href="pay.asp?nid=<%=nid%>&amp;sid=<%=sidd%>">返回上级页面</a><%=we0%>
<%=hr%>
<%=qingtian.qingsav("320")%><%=sou%><a href="chuwu.asp?sid=<%=sidd%>">我的物品</a>|<a href="shangchen.asp?sid=<%=sidd%>">商场</a>|<a href="index.asp?sid=<%=sidd%>">地盘</a><%=we0%>
<%   
else
conn.execute("update qingtian_user set [money]="&mone-page*mzf&",[money1]="&mone1-page*mzf1&" where sid='"&qingtian.Formatsid(sid)&"'")
conn.execute("update qingtian_shangpin set [recont]=[recont]+"&page&" where nid="&nid&"")
Set Rs_1 = Server.CreateObject("Adodb.Recordset")
Sql_1 = "select bid,nid,page,lib from qingtian_chuwu where bid="&bid&" and nid="&nid&""
		Rs_1.Open Sql_1,conn,1,3
		if not (rs_1.bof and rs_1.eof)  then
			rs_1("page")=rs_1("page")+page
			rs_1.update
		else
			rs_1.addnew
			rs_1("bid")=bid
			rs_1("nid")=nid
			rs_1("page")=page
			rs_1("lib")=lib
			rs_1.update
		end if
		Rs_1.close
             set Rs_1=nothing
session("tr")=1
qingtian.addong("购买了"&page&"个[url=/user/viewdaoju.asp?urls="&urls&"&nid="&nid&"&sid=[sid]]"&name&"[/url][img]"&tupic&"[/img]")
%>
<%=we%>恭喜你购买成功!系统从你的账户成功扣除<%=page*paym%><%=bi%><br/>你现在的余额为:<%=zi%><%=mzf0-page*paym%><%=bi%><%=zi0%><br/>1.<a href="pay.asp?nid=<%=nid%>&amp;sid=<%=sidd%>">继续返回购买</a><br/>2.<a href="chuwu.asp?act=2&amp;sid=<%=sidd%>">现在就使用</a><%=we0%>
<%=hr%>
<%=qingtian.qingsav("320")%><%=sou%><a href="chuwu.asp?sid=<%=sidd%>">我的物品</a>|<a href="shangchen.asp?sid=<%=sidd%>">商场</a>|<a href="index.asp?sid=<%=sidd%>">地盘</a><%=we0%>
<% 
end if  
else
%>
<%=we%><%=we0%>
<%=we%>购买出错!你的账户余额不足!<br/>你现在的账户余额为:<%=zi%><%=mzf0%><%=bi%><%=zi0%><br/>马上<a href="chongzhi.asp?sid=<%=sidd%>">充值我的<%=qingtian.bit%></a><br/>
<a href="pay.asp?nid=<%=nid%>&amp;sid=<%=sidd%>">返回上级页面</a><%=we0%>
<%=hr%>
<%=qingtian.qingsav("320")%><%=sou%><a href="chuwu.asp?sid=<%=sidd%>">我的物品</a>|<a href="shangchen.asp?sid=<%=sidd%>">商场</a>|<a href="index.asp?sid=<%=sidd%>">地盘</a><%=we0%>
<% 
end if 

End Select
else
Response.Redirect "/login.asp?sid=" & sidd & "&url=/user/pay.asp?sid="&sidd&"@@nid="&nid

end if		
end Function
%>
